#!/bin/sh

list_collumns ()
# $@ = FILE
{
    if test $# -eq 0; then 
        echo * | xargs -n1 echo
    for i in $@; do
        echo $i/* | xargs -n1 echo
    done
    unset i
}


tabex ()
# $@ = FILE...
{   
    if test -z $TAB_SPACES; then
        spaces='    '
    else
        spaces=''
        for i in `seq $TAB_SPACES`; do
            spaces="$spaces "
        done
    fi

    if test $# -eq 0; then
        sed -i "s/\t/$spaces/" $@
    else
        sed    "s/\t/$spaces/" <&0
    fi
    unset spaces
}


strip_whitespace ()
{
    if test $# -eq 0; then
        sed -E \
            -e "s/^[[:blank:]]*//" \
            -e "s/[[:blank:]]*$//" \
          <&0
    else
        sed -iE \
            -e "s/^[[:blank:]]*//" \
            -e "s/[[:blank:]]*$//" \
          $@ 
    fi
}


strip_comments ()
# Strip comments and trailing whitespace.
{
    if test $# -eq 0; then
        sed -iE
    else
        sed -iE \
            -e 's/[[:blank:]]*$//'   \
            -e "s/$LINE_COMMENT.*//" \
            -e "/$MULTILINE_COMMENT_OPEN/,/$MULTILINE_COMMENT_CLOSE/{
                   s/$MULTILINE_COMMENT_OPEN.*$//
                   s/^.*MULTILINE_COMMENT_CLOSE//
                   
                   
               }" \
          $@
}
